/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment_cp3120.DAO.mysqlDAO;

import assignment_cp3120.DAO.TransactionDAO;
import assignment_cp3120.dataObjects.Transaction;
import assignment_cp3120.DAO.mysqlDAO.MysqlDA0Factory;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
/**
 *
 * @author Richard Irons
 */
public class MysqlTransactionDAO implements TransactionDAO{
    public String updateTransactions(String transaction, String userID) {
        String transactionResult = new String();
        String update = new String("INSERT INTO TRANSACTION (TRANS_ID, USERNAME)"
                        + "VALUES ("
                        + "\" " + transaction + "\", \" "
                        + userID + ")"
                        );


        
        Connection c = MysqlDA0Factory.createConnection();        

        try {
            Statement statement = c.createStatement();
            int i = statement.executeUpdate(update);

            if(i == 1) {
                transactionResult = "Transaction was succesful: " + transaction;
            } else {
                transactionResult = null;
            }

        } catch(SQLException e) {
            System.out.println(e.getMessage());
        }
        return transactionResult;
    }
}
